package demo.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import demo.common.Result;
import demo.entity.One;
import demo.entity.Question;
import demo.entity.School;
import demo.mapper.OneMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin(maxAge = 3600)
@RestController
@RequestMapping("/selectone")
public class OneController {
  @Resource
  OneMapper oneMapper;
  @GetMapping
  public Result<?> findPage(@RequestParam(defaultValue = "") Integer onyear,
                            @RequestParam(defaultValue = "") Integer grade,
                            @RequestParam(defaultValue = "") String branch) {
//    LambdaQueryWrapper<One> wrapper = Wrappers.<One>lambdaQuery();
//    List<One> one = oneMapper.selectList(wrapper);
    QueryWrapper<One> wrapper = new QueryWrapper<>();
    wrapper.eq("onyear",onyear)
      .eq("grade",grade)
      .eq("branch",branch);
    One one =oneMapper.selectOne(wrapper);
    System.out.println("grade:"+grade);
    System.out.println("onyear:"+onyear);
    System.out.println("branch:"+branch);
    return Result.success(one);
    }


//  @GetMapping("/{onyear}-{grade}-{branch}")
//  public Result<?> selectone(@PathVariable Integer onyear,@PathVariable Integer grade,@PathVariable String branch){
//    QueryWrapper<One> wrapper = new QueryWrapper<>();
//    wrapper.eq("onyear",onyear)
//      .eq("grade",grade)
//      .eq("branch",branch);
//    One one =oneMapper.selectOne(wrapper);
//    System.out.println("grade:"+grade);
//    System.out.println("onyear:"+onyear);
//    System.out.println("branch:"+branch);
//    return Result.success(one);
//  }
}
